package com.mq;

import com.mq.rabbitmq.point.Send;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/8/19.
 */
@RestController
@RequestMapping("/rabbitmq")
public class RabbitmqController {
    @Autowired
    private Send send;

    @RequestMapping(value={"/tew"}, method= RequestMethod.GET)
    public String test() {
       return "1";
    }

    @RequestMapping(value={"/test"}, method= RequestMethod.GET)
    public String getUserList() {
            for(int i =0;i<1000000;i++) {
                send.sendMsg("这是第"+i +"个消息");
            }
        for(int i =0;i<2;i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    send.sendMsg("test2");
                }
            }).start();
        }
        return "1";
    }

    @RequestMapping(value={"/testMain"}, method= RequestMethod.GET)
    public String testMain() {
//        long start = System.currentTimeMillis();
//        for(int i =0;i<1000;i++) {
//            send.sendMsg("从节点从主同步节点的时候，这个消息还能发出去吗？");
//        }
        String s = null;
        s.toString();

        System.out.println("data ===="+(System.currentTimeMillis())+",ms");
        return "1";

    }
}
